package com.slc.datatransfer;

import net.sf.jxls.transformer.XLSTransformer;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;

import java.io.File;
import java.io.IOException;
import java.util.Map;

/**
 * Created by sunguangzhu on 2015/3/12.
 */
public class ExcelUtil {
    public static boolean generateExcel(String templatePath,Map<String,Object> map,String destPath) throws IOException, InvalidFormatException {
        XLSTransformer transformer = new XLSTransformer();
        transformer.transformXLS(templatePath , map, destPath);
        return true;
    }

    public static boolean generateExcel(String templatePath,Map<String,Object> map,String destDir,String fileName) throws IOException, InvalidFormatException {
        File file = new File(destDir);
        if (!file.exists()) {
            file.mkdirs();
        }
        return ExcelUtil.generateExcel(templatePath, map, destDir + fileName);
    }
}
